package com.wits.qso.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.sf.json.JSONObject;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name="qso_btable")/**基本课表*/
public class Btable extends BaseEntity {
	
	/**编码*/
	private String id;
	/**教师ID*/
	private Croom crmid;
	/**星期*/
	private String weday;
	/**课节*/
	private String calss;
	/**开始时间*/
	private Date time_start;
	/**结束时间*/
	private Date time_end;
	/**课程名称*/
	private Course couid;
	/**教师姓名*/
	private Teacher teaid;
	/**班级*/
	private Cls claid;
	/**科系*/
	private Dept dptid;
	/**年级*/
	private Grade gradeid;

	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name = "segment_value", value = "QSO_BTABLE_ID"),
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="10"),
								@Parameter(name="sq_format",value="%08d"),
								@Parameter(name="sq_prefix",value="CR")
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "btable_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "btable_crmid")
	public Croom getCrmid() {
		return crmid;
	}

	public void setCrmid(Croom crmid) {
		this.crmid = crmid;
	}

	@Column(name = "btable_weday",length=10)
	public String getWeday() {
		return weday;
	}

	public void setWeday(String weday) {
		this.weday = weday;
	}

	@Column(name = "btable_calss",length=10)
	public String getCalss() {
		return calss;
	}

	public void setCalss(String calss) {
		this.calss = calss;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "btable_time_start")
	public Date getTime_start() {
		return time_start;
	}

	public void setTime_start(Date time_start) {
		this.time_start = time_start;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "btable_time_end")
	public Date getTime_end() {
		return time_end;
	}

	public void setTime_end(Date time_end) {
		this.time_end = time_end;
	}

	@ManyToOne
	@JoinColumn(name = "btable_couid")
	public Course getCouid() {
		return couid;
	}

	public void setCouid(Course couid) {
		this.couid = couid;
	}

	@ManyToOne
	@JoinColumn(name = "btable_teaid")
	public Teacher getTeaid() {
		return teaid;
	}

	public void setTeaid(Teacher teaid) {
		this.teaid = teaid;
	}

	@ManyToOne
	@JoinColumn(name = "btable_claid")
	public Cls getClaid() {
		return claid;
	}

	public void setClaid(Cls claid) {
		this.claid = claid;
	}

	@ManyToOne
	@JoinColumn(name = "btable_dptid")
	public Dept getDptid() {
		return dptid;
	}

	public void setDptid(Dept dptid) {
		this.dptid = dptid;
	}

	@ManyToOne
	@JoinColumn(name = "btable_gradeid")
	public Grade getGradeid() {
		return gradeid;
	}

	public void setGradeid(Grade gradeid) {
		this.gradeid = gradeid;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		return JSONObject.fromObject(this,Btable.getBaseJsonConfig()).toString();
	}
}
